package com.szqhyxj.youxiangju.biz.partnerHome.home.equipmentreceipt;

import com.szqhyxj.youxiangju.sys.BaseResult;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by leung on 2018/11/21.
 */

public class EquipmentReceiptPresenter implements EquipmentReceiptContract.Presenter {

    EquipmentReceiptContract.View view;

    public EquipmentReceiptPresenter(EquipmentReceiptContract.View view) {
        this.view = view;
    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void init() {
        EquipmentReceiptModel.getpartnerEquipmentReceipt(1)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Consumer<BaseResult<EquipmentReceiptModel.EquipmentReceiptEntity>>() {
                    @Override
                    public void accept(BaseResult<EquipmentReceiptModel.EquipmentReceiptEntity> equipmentRepaymentEntityBaseResult) throws Exception {
                        view.showEquipmentReceiptInfo(equipmentRepaymentEntityBaseResult.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        view.showToast(throwable.getMessage());
                    }
                });


    }
}
